package com.ruoyi.develop.orderIronGoods.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.develop.projectBaseInfo.domain.ProjectBaseInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.orderIronGoods.domain.OrderIronGoods;
import com.ruoyi.develop.orderIronGoods.service.IOrderIronGoodsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 铁件物料编码Controller
 * @author lmm
 * @date 2025-06-06
 */
@RestController
@RequestMapping("/orderIronGoods/orderIronGoods")
public class OrderIronGoodsController extends BaseController {
    @Autowired
    private IOrderIronGoodsService orderIronGoodsService;

    /**
     * 查询铁件物料编码列表
     */
    @PreAuthorize("@ss.hasPermi('develop:OrderIronGoods:query')")
    @GetMapping("/list")
    public TableDataInfo list(OrderIronGoods entity) {
        startPage();
        List<OrderIronGoods> list = orderIronGoodsService.selectList(entity);
        return getDataTable(list);
    }

    /**
     * 导出铁件物料编码列表
     */
    @PreAuthorize("@ss.hasPermi('develop:OrderIronGoods:export')")
    @Log(title = "铁件物料编码", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderIronGoods entity) {
        List<OrderIronGoods> list = orderIronGoodsService.selectList(entity);
        ExcelUtil<OrderIronGoods> util = new ExcelUtil<OrderIronGoods>(OrderIronGoods. class);
        util.exportExcel(response, list, "铁件物料编码数据");
    }

    /**
     * 获取铁件物料编码详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:OrderIronGoods:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(orderIronGoodsService.selectById(id));
    }

    /**
     * 新增铁件物料编码
     */
    @PreAuthorize("@ss.hasPermi('develop:OrderIronGoods:add')")
    @Log(title = "铁件物料编码", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody OrderIronGoods entity) {
        return toAjax(orderIronGoodsService.insert(entity));
    }

    /**
     * 修改铁件物料编码
     */
    @PreAuthorize("@ss.hasPermi('develop:OrderIronGoods:edit')")
    @Log(title = "铁件物料编码", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody OrderIronGoods entity) {
        return toAjax(orderIronGoodsService.update(entity));
    }

    /**
     * 删除铁件物料编码
     */
    @PreAuthorize("@ss.hasPermi('develop:OrderIronGoods:remove')")
    @Log(title = "铁件物料编码", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(orderIronGoodsService.deleteByIds(ids));
    }


    /**
     * 导入铁件物料编码
     */
    @Log(title = "导入铁件物料编码", businessType = BusinessType.INSERT)
    @PostMapping("/importData")
    public AjaxResult importData(OrderIronGoods entity, MultipartFile file) {
        Map<String, Object> error = new HashMap<>();
        error = orderIronGoodsService.importData(entity,file);
        error.put("code", 200);
        return AjaxResult.success(error);
    }








}
